﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Collision;
using FarseerPhysics.Factories;
using EpicBall.ScreenSystem;

namespace EpicBall.Levels.Classes
{
    /// <summary>
    /// Items in the game level that are collectable
    /// </summary>
    public class Collectable : LevelObject
    {
        public Collectable(PhysicsGameScreen screen, Texture2D texture) : base(screen, texture) { }
        public Collectable(PhysicsGameScreen screen, Texture2D texture, int width, int height) : base(screen, texture, width, height) { }
        public Collectable(PhysicsGameScreen screen, Texture2D texture, Body body) : base(screen, texture, body) { }
        public Collectable(PhysicsGameScreen screen, Texture2D texture, Body body, int width, int height) : base(screen, texture, body, width, height) { }
        
        /// <summary>
        /// Set how much to increment score after
        /// getting the collectable
        /// </summary>

        /// <summary>
        /// Handle what happens on collision
        /// Note: Can override in subclasses : eg keys that open doors without adding score
        /// </summary>
        public override bool OnCollision(Fixture f1, Fixture f2, Contact contact)
        {
            if (f2.Body == _screen.Player)
            {
                _screen.Score += ScoreIncrement;
                _active = false;
            }
            return false;
        }

        public override string type()
        {
            return "collectable";
        }
    }
}
